package card;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class CardGame {
    public static final String[] suits = {"♣","♥","♦","♠"};
    public List<Card> generateCard(){
        List<Card> cardList = new ArrayList<>(); //用来存放牌
        //用来生成牌
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 13; j++) {
                String suit = suits[i];
                int rank = j;
                Card card = new Card(suit,rank);
                cardList.add(card);
            }
        }
        return cardList;

    }

    public void shuffle(List<Card> cardList ){
        Random random = new Random();
        int r = random.nextInt(52);  //生成一个随机数
        for (int i = 0; i < 52; i++) {
            swap(i,r,cardList);
        }


    }
    private void swap(int i,int j,List<Card> lit){
        Card card1 = new Card();
        card1 = lit.get(i);
        lit.set(i,lit.get(j));
        lit.set(j,card1);





    }
}
